package com.shanzhu.hospital.config;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Component //将该类声明为Spring组件，由Spring容器管理
public class InterceptorConfig implements WebMvcConfigurer {//提供自定义Spring MVC配置的能力
//拦截器配置类
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(
                new JwtInterceptor())//创建并注册一个实例
                .addPathPatterns("/**")//拦截所有请求路径
                //指定不需要被拦截的路径
                //文件导出
                .excludePathPatterns("/patient/pdf")
                //登录
                .excludePathPatterns("/**/login")
                //病患注册
                .excludePathPatterns("/**/addPatient");
    }

}
